var e = require("../../mybehaviors/imageSrcP");

Component({
    externalClasses: [ "custom-class" ],
    behaviors: [ e ],
    options: {
        virtualHost: !0
    },
    properties: {
        src: {
            value: "",
            type: String
        },
        customStyle: {
            value: "",
            type: String
        },
        mode: {
            value: "scaleToFill",
            type: String
        },
        webp: {
            value: !1,
            type: Boolean
        },
        showMenuByLongpress: {
            value: !1,
            type: Boolean
        },
        noneSrc: {
            value: !1,
            type: Boolean
        }
    },
    data: {
        url: "",
        loading: !1
    },
    observers: {
        src: function(e, t) {
            this.createImage();
        }
    },
    lifetimes: {
        attached: function() {
            this.setData({
                thumb_parameter: this.data.noneSrc ? "" : this.getyz_basic_info()
            });
        },
        detached: function() {
            this.detachedImage();
        }
    },
    ready: function() {},
    methods: {
        imgload: function(e) {
            this.triggerEvent("load", e);
        },
        imgerror: function(e) {
            this.triggerEvent("error", e);
        },
        createImage: function() {
            var e = this;
            this.detachedImage(), this.data.loading = !1, this._observer = wx.createIntersectionObserver(this), 
            this._observer.relativeToViewport({
                bottom: 30
            }).observe(".lazy-image", function(t) {
                t.intersectionRatio > 0 && 0 == e.data.loading && e.setData({
                    url: e.data.src ? e.data.src : "https://mini-app-img-1251768088.cos.ap-guangzhou.myqcloud.com/image.png",
                    loading: !0
                });
            });
        },
        detachedImage: function() {
            this._observer && this._observer.disconnect();
        }
    }
});